﻿<div ms-controller="LIST">
    <div class="btn-add">

        <button type="button" ms-if="datatype=='2'&&JHDATA.JHStatus=='0'" class="btn btn-success btn-lg" ms-click="sb()"><i class=" iconfont icon-bianji ft12 mr5"></i>上报数据</button>

        <button type="button" ms-if="datatype=='3'&&JHDATA.JHStatus=='0'" class="btn btn-danger  btn-lg" ms-click="zz()"><i class=" iconfont icon-bianji ft12 mr5"></i>中止计划</button>
        <button type="button" ms-if="datatype=='4'&&JHDATA.JHStatus=='0'" class="btn btn-success btn-lg" ms-click="th()"><i class=" iconfont icon-shanchu ft12 mr5"></i>恢复计划</button>

    </div>
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">类型：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectDataType('2')"><span class="active">待上报</span></li>
                <li ms-click="SelectDataType('3')"><span>已上报</span></li>
                <li ms-click="SelectDataType('4')"><span>已中止</span></li>

            </ul>
        </div>
    </div>

    <div class="default-tab ft14 pt20 grid">

        <div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>

    </div>
</div>
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.base.css" />
<link rel="stylesheet" href="/ViewV5/JS/YanGrid/jqwidgets/styles/jqx.office.css" />
<script src="/VIEWV5/JS/YanGrid/jqwidgets/jqgridall.js"></script>
<script>
    var goption = {
        columns: [
             {
                 text: '1', dataField: 'issel', columntype: 'checkbox', width: 40, editable: true, sortable: false, filterable: false, groupable: false, draggable: false, resizable: false,
                 renderer: function () {
                     return '<div style="margin-left: 10px; margin-top: 5px;"></div>';
                 },
                 rendered: function (element) {
                     $(element).jqxCheckBox({ theme: "office", width: 16, height: 16, animationShowDelay: 0, animationHideDelay: 0 });
                     // columnCheckBox = $(element);
                     $(element).on('change', function (event) {
                         var checked = event.args.checked;
                         if (checked == null || false) return;
                         var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
                         $("#jqxgrid").jqxGrid('beginupdate');

                         if (checked) {
                             $("#jqxgrid").jqxGrid('selectallrows');
                         }
                         else if (checked == false) {
                             $("#jqxgrid").jqxGrid('clearselection');
                         }

                         for (var i = 0; i < rowscount; i++) {
                             $("#jqxgrid").jqxGrid('setcellvalue', i, 'issel', event.args.checked);
                         }

                         $("#jqxgrid").jqxGrid('endupdate');
                     });
                     return true;
                 }
             },
              { text: 'ID', dataField: 'ID', hidden: "hides" },
             { text: '备注1', dataField: 'statusremark', hidden: "hides" },
              { text: '单位名称', dataField: 'dwname' },
            { text: '项目期别', dataField: 'Remark1', width: 120 },
              { text: '计划科目', dataField: 'FLName', width: 120 },
              { text: '合同编号', dataField: 'htbh', width: 120 },
              { text: '对方单位或个人', dataField: 'dfdw', width: 120 },
              { text: '合同内容', dataField: 'htnr', width: 120 },
              { text: '是否预付款', dataField: 'sfyfk', width: 120 },
              { text: '付款级次', dataField: 'fkjcid', width: 120 },
              { text: '合同节点', dataField: 'htjdid', width: 120 },
              { text: '应付款总额', dataField: 'yfkze', width: 120 },
              { text: '已付额', dataField: 'yfe', width: 120 },
              { text: '已付比', dataField: 'yfbl', width: 120 },
              { text: '截止当前欠款', dataField: 'dqqk', width: 120 },
              { text: '账龄(月)', dataField: 'zhangling', width: 120 },
              { text: '金额小计', dataField: 'jexj' },
              { text: '第一月', dataField: 'je1' },
              { text: '第二月', dataField: 'je2' },
              { text: '第三月', dataField: 'je3' },
              { text: '第一月描述', dataField: 'je1dec' },
              { text: '第二月描述', dataField: 'je2dec' },
              { text: '第三月描述', dataField: 'je3dec' },
              { text: '备注', dataField: 'remark' },
              { text: '第一周', dataField: 'week1' },
              { text: '第二周', dataField: 'week2' },
              { text: '第三周', dataField: 'week3' },
              { text: '第四周', dataField: 'week4' },
             {
                 text: '计划状态', dataField: 'status', filterable: false, editable: false,
                 groupable: false, draggable: false, resizable: false, width: 100, cellsrenderer: function (row, column, value) {
                     var data = $('#jqxgrid').jqxGrid('getrowdata', row);
                     var desc = ComFunJS.jhzcstatus(data.status);

                     var html = "";
                     //html = '<a href="#" onclick="tempindex.showzt(\'' + row + '\')"><p class="text-error" style="display: inline;font-size: 16px;    color: blue;">' + desc + '</p></a>';
                     var returns = ' <div style="overflow: hidden; text-overflow: ellipsis; padding-bottom: 2px; text-align: left; margin-right: 2px; margin-left: 4px; margin-top: 12px;">' + desc + '</div>';
                     return returns;
                 }
             },


        ]
    };

    var tempindex = avalon.define({
        $id: "LIST",
        tmpListData: [],
        JHDATA: {},
        selids: "",
        datatype: "2",
        SelectDataType: function (type) {
            tempindex.datatype = type;
            tempindex.GetLIST();

        },
        InitWigetData: function (obj) {
            tempindex.JHDATA = model.JHDATA;
            //显示的列名
            tempindex.GetLIST();
            $(".tab-box li").each(function (i) {
                $(this).click(function () {
                    $(this).addClass("active").siblings().removeClass("active");
                    $("#wrap>div:eq(" + i + ")").show().siblings().hide();
                });
            });

        },
        getcheckid: function () {
            tempindex.selids = "";
            var rowindexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
            for (var i = 0; i < rowindexes.length; i++) {
                var data = $('#jqxgrid').jqxGrid('getrowdata', rowindexes[i]);
                if (i == 0) {
                    tempindex.selids = data.ID;
                } else {
                    tempindex.selids = tempindex.selids + "," + data.ID;

                }
            }
            return tempindex.selids;
        },
        zz: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            ComFunJS.winconfirm("确认要中止改计划明细吗", function () {
                $.getJSON("/API/VIEWAPI.ashx?Action=JHGL_ZZZC", { P1: tempindex.selids }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        ComFunJS.winsuccess("操作成功");
                        tempindex.GetLIST();

                    }
                })
            }, function () { })
        },
        th: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            ComFunJS.winconfirm("确认要恢复该计划明细吗", function () {
                $.getJSON("/API/VIEWAPI.ashx?Action=JHGL_HFZC", { P1: tempindex.selids }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        ComFunJS.winsuccess("操作成功");
                        tempindex.GetLIST();

                    }
                })
            }, function () { })
        },
        sb: function () {
            if (!tempindex.getcheckid()) {
                ComFunJS.winwarning("请至少选择一条数据进行操作！");
                return;
            };
            ComFunJS.winconfirm("确认要上报数据吗", function () {
                $.getJSON("/API/VIEWAPI.ashx?Action=JHGL_SBZC", { P1: tempindex.selids }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        ComFunJS.winsuccess("操作成功");
                        tempindex.GetLIST();
                    }
                })
            }, function () { })
        },

        showzt: function () {
        },




        GetLIST: function () {
            try {
                $('#jqxgrid').jqxGrid('destroy');

            } catch (e) {

            }
            $(".grid").append('<div id="jqxgrid" class="jqxgrid" style="border-right:0;border-left:0;"></div>')
            model.search.seartype = "";
            $.getJSON('/API/VIEWAPI.ashx?Action=JHGL_GETKZZCMXLIST', { P1: tempindex.JHDATA.ID, P2: tempindex.datatype }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    for (var i = 0; i < resultData.Result.length; i++) {
                        resultData.Result[i].issel = "false";
                    }
                    ComFunJS.inithighgrid(goption, resultData.Result, "jqxgrid");
                    tempindex.tmpListData = resultData.Result;
                }
            })
        }
    }) //@ sourceURL=JHSR_MXLIST.js;
</script>
